// 请从字符串中找出一个不包含重复字符串的字串，计算出最长字串的长度
// 字串

function getLongstr(str: string): number {
  let left = 0;
  let right = 0;
  let res = 0

  for (let i = 0; i < str.length; i++) {
    right++
    const s = str.slice(left, right - left)
    const num = s.indexOf(str[i])
    if (num < 0) {
      res = Math.max(right - left, res)
    } else {
      left = left + num
    }
  }
  res = Math.max(right - left, res)
  console.log(res)
  return res
}

getLongstr('abcde')